﻿<div id="container" class="PageContainer">
    <hr />
    <a href="" style="margin-left:24px;" ng-click="backToList()" class="headerLink">back to list</a>
    <img id="waitImage" src="images/wait.gif" ng-show="loading" class="waitImage" style="z-index:100;"/>

    <form name="serverForm">
        <div class="row">
            <div class="col-xs-8">
                <input type="text" ng-model="server.Name" placeholder="Name" class="form-control" style="width:30em; margin-left:12px; font-size:18px; font-weight:bold;" />
            </div>
            <div class="col-xs-4">
                <select ng-model="server.InstallationEnvironment" class="form-control"
                        ng-options="env.Name for env in environments track by env.Id">
                </select>
            </div>
        </div>

        <div class="row">
            <div class="col-xs-8">
                <input type="text" ng-model="server.Description" placeholder="Description" class="form-control" style="width:40em; margin-left:12px;" />
            </div>
            <div class="col-xs-2">
                <label><input ng-model="server.EnableDebugLogging" type="checkbox" ng-true-value="true"
                              ng-false-value="false" ng-change="setIsDirty()">Debug Log</label>
            </div>
            <div class="col-xs-2">
                <label><input ng-model="server.Archived" type="checkbox" ng-true-value="true" ng-false-value="false"
                              ng-change="setIsDirty()">Archived</label>
            </div>
        </div>
    </form>

    <uib-accordion>
        <uib-accordion-group style="margin-left:12px; margin-top:12px;" is-open="true">
            <uib-accordion-heading>
                <span>Apps and Overrides</span>
            </uib-accordion-heading>
            <!-- ng-mousedown="$event.shiftKey && $event.preventDefault()" prevents IE from selecting other DOM elements on shift-click -->
            <div class="gridHalf" ui-grid="gridAppsWithGroup" ui-grid-selection ui-grid-resize-columns
                 ng-dblclick="editAppAndGroup()" ng-mousedown="$event.shiftKey && $event.preventDefault()"></div>
            <div style="margin-top: 12px; text-align: center;">
                <button class="btn btn-default" ng-click="addAppAndGroup();" ng-disabled="loading">Add</button>
                <button class="btn btn-default" ng-click="editAppAndGroup();" ng-disabled="loading || selectedAppsWithGroup.length == 0">Edit</button>
                <button class="btn btn-default" ng-click="removeAppAndGroup();" ng-disabled="loading || selectedAppsWithGroup.length == 0">Remove</button>
                <button class="btn btn-default" ng-click="saveServer();" ng-disabled="loading || !serverForm.$dirty">Save</button>
                <button class="btn btn-default" ng-click="install();" ng-disabled="loading || selectedAppsWithGroup.length == 0">Install</button>
            </div>
        </uib-accordion-group>
    </uib-accordion>	

    <uib-accordion>
        <uib-accordion-group style="margin-left:12px;">
            <uib-accordion-heading>
                <span>Custom Variable Groups</span>
            </uib-accordion-heading>
            <div class="gridLessThanHalf" ui-grid="gridGroups" ui-grid-selection ui-grid-resize-columns></div>
            <div style="margin-top: 12px; text-align: center;">
                <button class="btn btn-default" ng-click="addGroup();" ng-disabled="loading">Add</button>
                <button class="btn btn-default" ng-click="deleteGroups();" ng-disabled="selectedGroups.length == 0 || loading">Delete</button>
            </div>
        </uib-accordion-group>
    </uib-accordion>
</div>